<?php
include_once("../../includes/metodos.php");

function insert(){
	connectSql();
	
	$titulo = anti_injection($_POST['titulo']);
	$link = anti_injection($_POST['link']);
	$status = anti_injection($_POST['status']);
	$id_user = anti_injection($_POST['id_usuario']);
	$descricao = anti_injection($_POST['descricao']);
	$tags = anti_injection($_POST['tags']);
	
	$query = mysql_query("INSERT INTO econ_multimidia VALUES  (null, '$id_user', '$status', '$titulo', '$link', NOW(), NOW(), '$tags', '$descricao')");
	if($query){
		header('Location: index.php');
	}else{
		die(mysql_error());
	}
}

function edit($id){
	connectSql();
	
	$titulo = anti_injection($_POST['titulo']);
	$link = anti_injection($_POST['link']);
	$status = anti_injection($_POST['status']);
	$descricao = anti_injection($_POST['descricao']);
	$tags = anti_injection($_POST['tags']);
	
	$query = mysql_query("UPDATE econ_multimidia SET status='$status', titulo='$titulo', link='$link', editado=NOW(), tags='$tags', descricao='$descricao' WHERE id=".anti_injection($id));
	if($query){
		echo '<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
 							location.href="index.php";
					  </SCRIPT>';
	}else{
		die(mysql_error());
	}
}

function remove($id){
	connectSql();
	$query = mysql_query("DELETE FROM econ_multimidia WHERE id=".anti_injection($id));
	
	if($query){
		echo '<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">location.href="index.php";</SCRIPT>';
	}else{
		die(mysql_error());
	}
}